

<?php
if ($this->code == "0"){
    echo "<legend>";
    echo $this->msg;
    echo "</legend>";
}else echo $this->msg;

if ($this->code == ""){
?>

<legend>Transfer Point</legend>
<div class="row clearfix">
<div class="col-md-8 column">
<form method="post" id="frm" name="frm">

                <?php //echo $this->today;?>

                
                <br>
                <!-- fromAcc input-->
                <div class="form-group">
                    <label class="control-label">Dari Nomor Akun</label>
           
                        <select id="fromAcc" name="fromAcc" class="form-control">
                            <?php
                            
                           foreach ($this->accountList as $oAcc) {
               
                                    echo "<option value='".$oAcc['account_num']."'>". $oAcc['account_num'] ." (". $oAcc['account_name'] .")</option>";
                           }
                           ?>
                        </select>
                </div>
                <br>
                <div class="form-group">
                    <label class="control-label">Ke Nomor Akun:</label>
                </div>

                <!-- toAcc input-->
                <div class="form-group">
                    <label class="control-label"><input type="radio" required id="toRadio" name="toRadio" value="1" onclick="pilihRek(this)"/> Dari Daftar Pribadi</label>
                   
                    <select id="toAcc" name="toAcc" class="form-control" disabled>
                            <option value=''>== Pilih ==</option>   
                            <?php
                           foreach ($this->accPersonalList as $oAcc) {
                                    echo "<option value='".$oAcc['account_num']."'>". $oAcc['account_num'] ." (". $oAcc['trans_name'] .")</option>";
                           }
                           ?>
                        </select>
                </div>

                <!-- toOtherAcc input-->
                <div class="form-group">
                        <label class="control-label"><input type="radio" required id="toRadio" name="toRadio" value="2" onclick="pilihRek(this)"/> Ke Nomor Akun Lainnya</label>
                        <input id="toOtherAcc" name="toOtherAcc" type="text" placeholder="Nomor Rekening"
                        class="form-control" disabled required>
                </div>
                
               

                <!-- saveAs input-->
                <div class="form-group">
                    <label class="control-label"><input type="checkbox" id="cbSave" name="cbSave" disabled onchange="klikSave(this)"/> Simpan dalam daftar pribadi</label>
                        <input id="saveAs" name="saveAs" type="text" placeholder="Simpan Sebagai"
                        class="form-control" disabled required>
                </div>

                <!-- amount input-->
                <div class="form-group">
                                      
                        <input id="amount" name="amount" type="text" placeholder="Jumlah transfer"
                        class="form-control" required type="number" onkeypress='return validateNumber(event)'>
                        <p class="help-block">Cth: 1500000 (Tanpa titik/koma)</p>
                </div>
                <!-- remark input-->
                <div class="form-group">

                    <div class="controls">
                        <textarea id="remark" name="remark" type="text" placeholder="Catatan"
                        class="form-control"></textarea>

                        <p class="help-block"></p>
                    </div>
                </div>

                <!-- submit btn-->
                <div class="form-group">
                    <label class="control-label"></label>
                        <button class="btn btn-default" type="submit" id="btnSubmit" name="btnSubmit">
                        Submit</button> <div id="div_result"></div>
                </div>

        </form>
</div>
</div>
        <script>

        function pilihRek(obj){
            
            if (obj.value == "1"){
                $("#toAcc").removeAttr('disabled');

                $("#toOtherAcc").val('');
                $("#toOtherAcc").attr('disabled','disabled');


                $("#cbSave").removeAttr('checked');
                $("#cbSave").attr('disabled','disabled');

                
            }else{

                $("#toAcc").attr('disabled','disabled');

                $("#toOtherAcc").removeAttr('disabled');
                $("#cbSave").removeAttr('disabled');
                
            }
        }

        function klikSave(obj){
            if(obj.checked){
                $("#saveAs").removeAttr('disabled');
            }else{
                $("#saveAs").val('');
                $("#saveAs").attr('disabled','disabled');
            }
        }

        function validateNumber(evt) {

            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
          }

        /* Attach a submit handler to the form */
        $("#frm").submit(function(event) {

            /* Stop form from submitting normally */
            event.preventDefault();

            /* Clear result div*/
            $("#div_result").html('');
            $("#btnSubmit").html('Memproses...');
            $("#btnSubmit").attr('disabled','disabled');

            /* Get some values from elements on the page: */
            var values = $(this).serialize();

            var msg = [];

            /* Send the data using post and put the results in a div */
            
            $.ajax({
                url: "<?php echo $this->baseUrl() ?>/transfer/transferpoint/",
                type: "post",
                data: values,
                success: function(response, opts){

                    var cekSess = response.toUpperCase().search("SESSION TIMEOUT");

                    if (cekSess < 0){

                        var cekStatus = response.toUpperCase().search("ERROR");

                        if (cekStatus < 0){
                            $("#div_content").html(response);
                        }else{
                            var resp = response.replace('ERROR', '');

                            msg.push('<span>'+resp+'</span>');
                            $.messager.alert('Info', msg.join('<br/>'));

                            //$("#div_result").html(resp);
                            $("#btnSubmit").removeAttr('disabled');
                            $("#btnSubmit").html('Submit');

                    
                        }
                    }else{
                        location.href='<?php echo $this->baseUrl() ?>/index/login/msg/Session Timeout silahkan login kembali !';
                    }
                },
                error:function(response, opts){
                    //alert("failure");
                    msg.push('<span>'+response+'</span>');
                    $.messager.alert('Info', msg.join('<br/>'));

                    $("#btnSubmit").removeAttr('disabled');
                }
            });
            

        });

        </script>

        <?php } ?>
    